<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>browser_test.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_labs_useragent_browser_test.js.html">browser_test.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2013 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Unit tests for goog.labs.userAgent.browser.
<a name="line17"></a> */
<a name="line18"></a>
<a name="line19"></a>goog.provide(&#39;goog.labs.userAgent.browserTest&#39;);
<a name="line20"></a>
<a name="line21"></a>goog.require(&#39;goog.labs.userAgent.browser&#39;);
<a name="line22"></a>goog.require(&#39;goog.labs.userAgent.testAgents&#39;);
<a name="line23"></a>goog.require(&#39;goog.labs.userAgent.util&#39;);
<a name="line24"></a>goog.require(&#39;goog.testing.jsunit&#39;);
<a name="line25"></a>
<a name="line26"></a>goog.setTestOnly(&#39;goog.labs.userAgent.browserTest&#39;);
<a name="line27"></a>
<a name="line28"></a>function setUp() {
<a name="line29"></a>  goog.labs.userAgent.util.setUserAgent(null);
<a name="line30"></a>}
<a name="line31"></a>
<a name="line32"></a>function testOpera10() {
<a name="line33"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line34"></a>      goog.labs.userAgent.testAgents.OPERA_10);
<a name="line35"></a>  assertTrue(goog.labs.userAgent.browser.isOpera());
<a name="line36"></a>  assertVersion(&#39;10.00&#39;);
<a name="line37"></a>  assertVersionBetween(&#39;10.00&#39;, &#39;10.10&#39;);
<a name="line38"></a>}
<a name="line39"></a>
<a name="line40"></a>function testOperaMac() {
<a name="line41"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line42"></a>      goog.labs.userAgent.testAgents.OPERA_MAC);
<a name="line43"></a>  assertTrue(goog.labs.userAgent.browser.isOpera());
<a name="line44"></a>  assertVersion(&#39;11.52&#39;);
<a name="line45"></a>  assertVersionBetween(&#39;11.50&#39;, &#39;12.00&#39;);
<a name="line46"></a>}
<a name="line47"></a>
<a name="line48"></a>function testOperaLinux() {
<a name="line49"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line50"></a>      goog.labs.userAgent.testAgents.OPERA_LINUX);
<a name="line51"></a>  assertTrue(goog.labs.userAgent.browser.isOpera());
<a name="line52"></a>  assertVersion(&#39;11.50&#39;);
<a name="line53"></a>  assertVersionBetween(&#39;11.00&#39;, &#39;12.00&#39;);
<a name="line54"></a>}
<a name="line55"></a>
<a name="line56"></a>function testOpera15() {
<a name="line57"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line58"></a>      goog.labs.userAgent.testAgents.OPERA_15);
<a name="line59"></a>  assertTrue(goog.labs.userAgent.browser.isOpera());
<a name="line60"></a>  assertVersion(&#39;15.0.1147.100&#39;);
<a name="line61"></a>  assertVersionBetween(&#39;15.00&#39;, &#39;16.00&#39;);
<a name="line62"></a>}
<a name="line63"></a>
<a name="line64"></a>function testIE6() {
<a name="line65"></a>  goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_6);
<a name="line66"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line67"></a>  assertVersion(&#39;6.0&#39;);
<a name="line68"></a>  assertVersionBetween(&#39;5.0&#39;, &#39;7.0&#39;);
<a name="line69"></a>}
<a name="line70"></a>
<a name="line71"></a>function testIE7() {
<a name="line72"></a>  goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_7);
<a name="line73"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line74"></a>  assertVersion(&#39;7.0&#39;);
<a name="line75"></a>}
<a name="line76"></a>
<a name="line77"></a>function testIE8() {
<a name="line78"></a>  goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_8);
<a name="line79"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line80"></a>  assertVersion(&#39;8.0&#39;);
<a name="line81"></a>  assertVersionBetween(&#39;7.0&#39;, &#39;9.0&#39;);
<a name="line82"></a>}
<a name="line83"></a>
<a name="line84"></a>function testIE8Compatibility() {
<a name="line85"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line86"></a>      goog.labs.userAgent.testAgents.IE_8_COMPATIBILITY);
<a name="line87"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line88"></a>  assertVersion(&#39;8.0&#39;);
<a name="line89"></a>}
<a name="line90"></a>
<a name="line91"></a>function testIE9() {
<a name="line92"></a>  goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_9);
<a name="line93"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line94"></a>  assertVersion(&#39;9.0&#39;);
<a name="line95"></a>  assertVersionBetween(&#39;8.0&#39;, &#39;10.0&#39;);
<a name="line96"></a>}
<a name="line97"></a>
<a name="line98"></a>function testIE9Compatibility() {
<a name="line99"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line100"></a>      goog.labs.userAgent.testAgents.IE_9_COMPATIBILITY);
<a name="line101"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line102"></a>  assertVersion(&#39;9.0&#39;);
<a name="line103"></a>}
<a name="line104"></a>
<a name="line105"></a>function testIE10() {
<a name="line106"></a>  goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_10);
<a name="line107"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line108"></a>  assertVersion(&#39;10.0&#39;);
<a name="line109"></a>  assertVersionBetween(&#39;10.0&#39;, &#39;11.0&#39;);
<a name="line110"></a>}
<a name="line111"></a>
<a name="line112"></a>function testIE10Compatibility() {
<a name="line113"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line114"></a>      goog.labs.userAgent.testAgents.IE_10_COMPATIBILITY);
<a name="line115"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line116"></a>  assertVersion(&#39;10.0&#39;);
<a name="line117"></a>}
<a name="line118"></a>
<a name="line119"></a>function testIE11() {
<a name="line120"></a>  goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_11);
<a name="line121"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line122"></a>  assertVersion(&#39;11.0&#39;);
<a name="line123"></a>  assertVersionBetween(&#39;10.0&#39;, &#39;12.0&#39;);
<a name="line124"></a>}
<a name="line125"></a>
<a name="line126"></a>function testIE11CompatibilityMSIE7() {
<a name="line127"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line128"></a>      goog.labs.userAgent.testAgents.IE_11_COMPATIBILITY_MSIE_7);
<a name="line129"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line130"></a>  assertVersion(&#39;11.0&#39;);
<a name="line131"></a>}
<a name="line132"></a>
<a name="line133"></a>function testIE11CompatibilityMSIE9() {
<a name="line134"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line135"></a>      goog.labs.userAgent.testAgents.IE_11_COMPATIBILITY_MSIE_9);
<a name="line136"></a>  assertTrue(goog.labs.userAgent.browser.isIE());
<a name="line137"></a>  assertVersion(&#39;11.0&#39;);
<a name="line138"></a>}
<a name="line139"></a>
<a name="line140"></a>function testFirefox19() {
<a name="line141"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line142"></a>      goog.labs.userAgent.testAgents.FIREFOX_19);
<a name="line143"></a>  assertTrue(goog.labs.userAgent.browser.isFirefox());
<a name="line144"></a>  assertVersion(&#39;19.0&#39;);
<a name="line145"></a>  assertVersionBetween(&#39;18.0&#39;, &#39;20.0&#39;);
<a name="line146"></a>}
<a name="line147"></a>
<a name="line148"></a>function testFirefoxWindows() {
<a name="line149"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line150"></a>      goog.labs.userAgent.testAgents.FIREFOX_WINDOWS);
<a name="line151"></a>  assertTrue(goog.labs.userAgent.browser.isFirefox());
<a name="line152"></a>  assertVersion(&#39;14.0.1&#39;);
<a name="line153"></a>  assertVersionBetween(&#39;14.0&#39;, &#39;15.0&#39;);
<a name="line154"></a>}
<a name="line155"></a>
<a name="line156"></a>function testFirefoxLinux() {
<a name="line157"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line158"></a>      goog.labs.userAgent.testAgents.FIREFOX_LINUX);
<a name="line159"></a>  assertTrue(goog.labs.userAgent.browser.isFirefox());
<a name="line160"></a>  assertVersion(&#39;15.0.1&#39;);
<a name="line161"></a>}
<a name="line162"></a>
<a name="line163"></a>function testChromeAndroid() {
<a name="line164"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line165"></a>      goog.labs.userAgent.testAgents.CHROME_ANDROID);
<a name="line166"></a>  assertTrue(goog.labs.userAgent.browser.isChrome());
<a name="line167"></a>  assertVersion(&#39;18.0.1025.133&#39;);
<a name="line168"></a>  assertVersionBetween(&#39;18.0&#39;, &#39;19.0&#39;);
<a name="line169"></a>  assertVersionBetween(&#39;17.0&#39;, &#39;18.1&#39;);
<a name="line170"></a>}
<a name="line171"></a>
<a name="line172"></a>function testChromeIphone() {
<a name="line173"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line174"></a>      goog.labs.userAgent.testAgents.CHROME_IPHONE);
<a name="line175"></a>  assertTrue(goog.labs.userAgent.browser.isChrome());
<a name="line176"></a>  assertVersion(&#39;22.0.1194.0&#39;);
<a name="line177"></a>  assertVersionBetween(&#39;22.0&#39;, &#39;23.0&#39;);
<a name="line178"></a>  assertVersionBetween(&#39;22.0&#39;, &#39;22.10&#39;);
<a name="line179"></a>}
<a name="line180"></a>
<a name="line181"></a>function testChromeMac() {
<a name="line182"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line183"></a>      goog.labs.userAgent.testAgents.CHROME_MAC);
<a name="line184"></a>  assertTrue(goog.labs.userAgent.browser.isChrome());
<a name="line185"></a>  assertVersion(&#39;24.0.1309.0&#39;);
<a name="line186"></a>  assertVersionBetween(&#39;24.0&#39;, &#39;25.0&#39;);
<a name="line187"></a>  assertVersionBetween(&#39;24.0&#39;, &#39;24.10&#39;);
<a name="line188"></a>}
<a name="line189"></a>
<a name="line190"></a>function testSafariIpad() {
<a name="line191"></a>  goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IPAD_6);
<a name="line192"></a>  assertTrue(goog.labs.userAgent.browser.isSafari());
<a name="line193"></a>  assertVersion(&#39;6.0&#39;);
<a name="line194"></a>  assertVersionBetween(&#39;5.1&#39;, &#39;7.0&#39;);
<a name="line195"></a>}
<a name="line196"></a>
<a name="line197"></a>function testSafari6() {
<a name="line198"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line199"></a>      goog.labs.userAgent.testAgents.SAFARI_6);
<a name="line200"></a>  assertTrue(goog.labs.userAgent.browser.isSafari());
<a name="line201"></a>  assertVersion(&#39;6.0&#39;);
<a name="line202"></a>  assertVersionBetween(&#39;6.0&#39;, &#39;7.0&#39;);
<a name="line203"></a>}
<a name="line204"></a>
<a name="line205"></a>function testSafariIphone() {
<a name="line206"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line207"></a>      goog.labs.userAgent.testAgents.SAFARI_IPHONE_6);
<a name="line208"></a>  assertTrue(goog.labs.userAgent.browser.isSafari());
<a name="line209"></a>  assertVersion(&#39;6.0&#39;);
<a name="line210"></a>  assertVersionBetween(&#39;5.0&#39;, &#39;7.0&#39;);
<a name="line211"></a>}
<a name="line212"></a>
<a name="line213"></a>function testAndroidBrowser235() {
<a name="line214"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line215"></a>      goog.labs.userAgent.testAgents.ANDROID_BROWSER_235);
<a name="line216"></a>  assertTrue(goog.labs.userAgent.browser.isAndroidBrowser());
<a name="line217"></a>  assertVersion(&#39;4.0&#39;);
<a name="line218"></a>  assertVersionBetween(&#39;3.0&#39;, &#39;5.0&#39;);
<a name="line219"></a>}
<a name="line220"></a>
<a name="line221"></a>function testAndroidBrowser403() {
<a name="line222"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line223"></a>      goog.labs.userAgent.testAgents.ANDROID_BROWSER_403);
<a name="line224"></a>  assertTrue(goog.labs.userAgent.browser.isAndroidBrowser());
<a name="line225"></a>  assertVersion(&#39;4.0&#39;);
<a name="line226"></a>  assertVersionBetween(&#39;3.0&#39;, &#39;5.0&#39;);
<a name="line227"></a>}
<a name="line228"></a>
<a name="line229"></a>function testAndroidBrowser233() {
<a name="line230"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line231"></a>      goog.labs.userAgent.testAgents.ANDROID_BROWSER_233);
<a name="line232"></a>  assertTrue(goog.labs.userAgent.browser.isAndroidBrowser());
<a name="line233"></a>  assertVersion(&#39;4.0&#39;);
<a name="line234"></a>  assertVersionBetween(&#39;3.0&#39;, &#39;5.0&#39;);
<a name="line235"></a>}
<a name="line236"></a>
<a name="line237"></a>function testSilk() {
<a name="line238"></a>  goog.labs.userAgent.util.setUserAgent(
<a name="line239"></a>      goog.labs.userAgent.testAgents.KINDLE_FIRE);
<a name="line240"></a>  assertTrue(goog.labs.userAgent.browser.isSilk());
<a name="line241"></a>  assertVersion(&#39;2.1&#39;);
<a name="line242"></a>}
<a name="line243"></a>
<a name="line244"></a>function assertVersion(version) {
<a name="line245"></a>  assertEquals(version, goog.labs.userAgent.browser.getVersion());
<a name="line246"></a>}
<a name="line247"></a>
<a name="line248"></a>function assertVersionBetween(lowVersion, highVersion) {
<a name="line249"></a>  assertTrue(goog.labs.userAgent.browser.isVersionOrHigher(lowVersion));
<a name="line250"></a>  assertFalse(goog.labs.userAgent.browser.isVersionOrHigher(highVersion));
<a name="line251"></a>}
</pre>


</body>
</html>
